<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.codeplex.springsurv.dataaccess.mappers.UsersMapper">

	<cache />

	<resultMap type="com.codeplex.springsurv.User" id="userMap">
		<id property="strNick" column="userNick" javaType="java.lang.String"
			jdbcType="VARCHAR" />
		<result property="strPass" column="userPass" javaType="java.lang.String"
			jdbcType="VARCHAR" />
	</resultMap>

	<select id="getAllUsers" parameterType="list" resultMap="userMap">
		SELECT * FROM users;
	</select>

	<insert id="insertUser">
		INSERT INTO users(userNick, userPass)
		VALUES(#{user.strNick}, #{user.strPass});
	</insert>
	
	<select id="getUserByNickAndPass" parameterType="list" resultMap="userMap" >
		SELECT userNick, userPass FROM users WHERE userNick= #{strNick} AND userPass=#{strPass};
	</select>
	
	<select id="getUserByNick" parameterType="list" resultMap="userMap" >
		SELECT userNick FROM users WHERE userNick= #{strNick};
	</select>
	
	<select id="existsNick" parameterType="list" resultMap="userMap" >
		SELECT * FROM users WHERE userNick=#{nick};
	</select>
</mapper>